function setUpButtons(){

	$("#PBaccHolder").accordion();
	
	$('#charts_viewMore').bind('click', function(){
		urlParts = window.location.href.match(/=(\w)$/);
		window.location = "chartlist?g=" + urlParts[1];
	});
	
	$('#books_viewMore').bind('click', function(){
		urlParts = window.location.href.match(/=(\w)$/);
		window.location = "booklist?g=" + urlParts[1];		
	});
	
	// Bind the leave group button (if its there)
	$("button#leave_group").bind('click', function(){
		urlParts = window.location.href.match(/=(\w)$/);
		sendData = {'action': 'leave', 'gID' : urlParts[1], 'l' : PicBoard.language};
		$.ajax({
			type: "POST",
			url: PicBoard.baseURL + "rsrc.php?req=groupAction",
			data: sendData,
			success: function(msg){
				jQuery.facebox(msg);
				
				// Bind the decline button to close the dialog box.
				$("#leave_group_decline").bind('click', function(){
					jQuery.facebox.close();
				});				
				
				// Bind the accept button to send off an AJAX request to confirm leaving the group.
				$("#leave_group_confirmation").bind('click', function(){
					urlParts = window.location.href.match(/=(\w)$/);
					toSend = {'action': 'confirmleave', 'gID' : urlParts[1], 'l' : PicBoard.language};
					jQuery.facebox.close()
					// Send the request
					$.ajax({
						type: "POST",
						url: PicBoard.baseURL + "rsrc.php?req=groupAction",
						data: toSend,
						success: function(msg){
							jQuery.facebox(msg.message);
						}
					});
				});
			}
		});
		
	});
	
	// Bind the join group button if its there
	$('button#join_group').bind('click', function(){
		urlParts = window.location.href.match(/=(\w)$/);
		sendData = {'action': 'join', 'gID' : urlParts[1], 'l' : PicBoard.language};	
		
		$.ajax({
			type: "POST",
			url: PicBoard.baseURL + "rsrc.php?req=groupAction",
			data: sendData,
			dataType: 'json',
			success: function(msg){
				//alert(msg);
				
				if(msg.statusCode == "200"){
					// Success
					if(msg.payload.action == "JoinRequest"){
						$("button#join_group").attr('disabled', 'true');
						showMessagePane("Awaiting confirmation for this group", null, null);
					} else {
						window.location = window.location.href;
					}
				}
				
				if(msg.status == "failure"){
					alert(msg.message);
				}
				
			}
		});
	});
	
	// Check to see if we're awaiting confirmation.
	
	if($("button#leave_group").attr('disabled')){
		showMessagePane("Awaiting confirmation for this group", null, null);
	}
	
	
	
	$('#imagesets_add').bind('click', function(){

		
		var qs = window.location.search;
		// Get the id from the request URL
		var id = qs.match(/\?.*?id=(\w+)/);		

		$.ajax({url: PicBoard.baseURL + 'rsrc.php?req=getUploadDialog', data: { groupID: id[1] },
			success: function(data){
				jQuery.facebox(data);
				// IE sucks
				if($.browser.msie != true) $('button').button();
				
				var qs = window.location.search;
				// Get the id from the request URL
				var id = qs.match(/\?.*?id=(\w+)/);				
				
				$('input[name=groupID]').val(id[1]);
				
				$('input[type=file][name=image]').change(function(){
					fileSplit = $('input[type=file]').val().match(/(.*?)\.[\w]{2,4}$/);
					$('input[name=fileName]').val(fileSplit[1]);
				});
				
				$('#uploadFileButton').bind('click', function(){
					// Get the filename
					filetype = $('input[type=file]').val().match(/\.(\w{2,4})$/);

					if($('input[type=file]').val() == ""){
						PicBoard.getTranslations(['lang_226_invalidFiletype'], function(data){
							alert(data.payload.lang_226_invalidFiletype);
						});		
					} else {
						filetype = filetype[1].toLowerCase();

						if(filetype == "png" || filetype == "jpg" || filetype == "jpeg" || filetype == "gif"){
							$("#uploadForm").submit();
						} else {
							PicBoard.getTranslations(['lang_226_invalidFiletype'], function(data){
								alert(data.payload.lang_226_invalidFiletype);
							});
						}
					}
				});
			},
			type: "POST"
		});
	});
	
	$('#imagesets_create').bind('click', function(){
		getFragment("newImageset", function(data){
			jQuery.facebox(data);
		
			var qs = window.location.search;
			// Get the id from the request URL
			var id = qs.match(/\?.*?id=(\w+)/);				
			
			$('input[name=groupID]').val(id[1]);			
			
			$('#saveImageset').bind('click', function(){
				$.post(PicBoard.baseURL + 'rsrc.php?req=createImageSet',$('#uploadForm').serialize(), function(data){
					if(data.statusCode == 200){
						window.location = window.location;
					} else {
						jQuery.facebox(data.message);
					}
				}, 'json' );				
			});
		});
		
	});	
}

// Queue setUpButtons() to run when the document is ready.
PicBoard.addLoadEvent( "setUpButtons()" );